#include <QtGui>
#include "link.h"

#ifndef PORT_H
#define PORT_H

class Port : public QGraphicsItem
{
  Q_DECLARE_TR_FUNCTIONS(Port);

public:
  enum { WIDTH = 6, HEIGHT =4 };
  Port();
  ~Port();

  //void setOutlineColor(const QColor &color) { myOutlineColor = color; update(); }
  //QColor outlineColor() const { return myOutlineColor; }
  void setActiveColor(const QColor &color) { myActiveColor = color; update(); }
  QColor activeColor() const { return myActiveColor; }

  void addLink(Link * link);
  void removeLink(Link * link);
  
  QRectF boundingRect() const;
  QPainterPath shape() const;
  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

protected:
  //void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
  //void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
  void hoverEnterEvent(QGraphicsSceneMouseEvent *event);
  void hoverLeaveEvent(QGraphicsSceneMouseEvent *event);
  QVariant itemChange(GraphicsItemChange change, const QVariant &value);

private:
  QRectF outlineRect() const;
  int roundness(double size) const;
  
  Link* myLink;
  QColor myActiveColor;
  QColor myInactiveColor;
};
#endif

